#!/bin/bash
port="/dev/ttyS32"
baud=$((921600))
file="$1"

if [ -z "$1" ]; then
    echo "Flashes a wave file to the partition for the speech recognition thing to parse it."
    echo "Usage: $0 file.wav [/dev/ttyS32 [921600]]"
    exit 0
fi

if [ -n "$2" ]; then
    port="$2"
fi
if [ -n "$3" ]; then
    baud="$3"
fi

python ${IDF_PATH}/components/esptool_py/esptool/esptool.py \
        --port $port --baud $baud --before default_reset --after hard_reset write_flash \
        --flash_mode dio --flash_freq 40m --flash_size detect 0x00444000 "$file"


# source flash_voicedata.sh managed_components/espressif__esp-sr/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaole.dat  /dev/ttyACM0
# source flash_voicedata.sh managed_components/espressif__esp-sr/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaoxin_small.dat  /dev/ttyACM0